package com.data.modules.online.cgreport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgreport.entity.OnlCgreportItem;
import com.data.modules.online.cgreport.mapper.OnlCgreportItemMapper;
import com.data.modules.online.cgreport.service.IOnlCgreportItemService;
import com.data.modules.online.cgreport.util.CgReportSqlUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("onlCgreportItemServiceImpl")
public class OnlCgreportItemServiceImpl extends ServiceImpl<OnlCgreportItemMapper, OnlCgreportItem> implements IOnlCgreportItemService {
    private static /* synthetic */ java.lang.Object m340a(java.lang.invoke.SerializedLambda r4) {
        /*
        // Method dump skipped, instructions count: 204
        */
        throw new UnsupportedOperationException("Method not decompiled: com.data.modules.online.cgreport.service.p016a.OnlCgreportItemServiceImpl.m340a(java.lang.invoke.SerializedLambda):java.lang.Object");
    }

    
    @Override
    @Cacheable(key = "'search-'+#cgrheadId", value = {"sys:cache:online:rp"})
    public List<Map<String, String>> getAutoListQueryInfo(String cgrheadId) {
        LambdaQueryWrapper<OnlCgreportItem> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgreportItem::getCgrheadId, cgrheadId);
        lambdaQueryWrapper.eq(OnlCgreportItem::getIsSearch, 1);
        List list = this.list(lambdaQueryWrapper);
        ArrayList arrayList = new ArrayList();
        int i = 0;

        HashMap hashMap;
        for(Iterator iterator = list.iterator(); iterator.hasNext(); arrayList.add(hashMap)) {
            OnlCgreportItem next = (OnlCgreportItem) iterator.next();
            hashMap = new HashMap();
            hashMap.put("label", next.getFieldTxt());
            String dictCode = next.getDictCode();
            if (ConvertUtils.isNotEmpty(dictCode)) {
                if (CgReportSqlUtil.isSelectSql(dictCode)) {
                    hashMap.put("view", "search");
                    hashMap.put("sql", dictCode);
                } else {
                    hashMap.put("view", "list");
                }
            } else {
                hashMap.put("view", next.getFieldType().toLowerCase());
            }

            hashMap.put("mode", ConvertUtils.isEmpty(next.getSearchMode()) ? "single" : next.getSearchMode());
            hashMap.put("field", next.getFieldName());
            ++i;
            if (i > 2) {
                hashMap.put("hidden", "1");
            }
        }

        return arrayList;
    }
}
